package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccMaterialManufacturer;
import com.bzkj.basicinfo.domain.ncc.dto.NccMaterialManufacturerDto;
import com.bzkj.basicinfo.service.ncc.NccMaterialManufacturerService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(tags = "生产商信息")
@RestController
@RequestMapping("/ncc")
public class NccMaterialManufacturerController extends BaseController
{

    @Autowired
    private NccMaterialManufacturerService materialManufacturerService;

    /**
     * NCC单据分类
     */
    @GetMapping({"/nccMaterialManufacturerJob", "/nccMaterialManufacturerJob/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:MaterialManufacturer:Job')")
    public void nccMaterialManufacturerJob(@PathVariable(required = false) String all)
    {
        materialManufacturerService.updateNccMaterialManufacturerJob(all);
    }

    /**
     * 根据条件查询生产商信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 10:17:28
     * @Param dto
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccMaterialManufacturerData")
    public TableDataInfo findNccMaterialManufacturerData(NccMaterialManufacturerDto dto)
    {
        startPage();
        return getDataTable(materialManufacturerService.findNccMaterialManufacturerData(dto));
    }

    /**
     * 根据code修改生产商状态
     *
     * @Author wangzhichao
     * @Date 2024/12/10 10:25:12
     * @Param code
     * @Param status
     */
    @ApiOperation("修改状态接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:stateEdit')")
    @PutMapping("nccMaterialManufacturerEnableStatusUpdate")
    @LogC(title = "ncc生产商信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_material_manufacturer", pkFieldNames = "code", content = "' 生产商编码：'+#code")
    public AjaxResult nccMaterialManufacturerEnableStatusUpdate(@RequestParam String code, @RequestParam String status)
    {
        return materialManufacturerService.nccMaterialManufacturerEnableStatusUpdate(code, status);
    }

    /**
     * 根据code修改生产商信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 10:32:38
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("nccMaterialManufacturerUpdate")
    @LogC(title = "ncc生产商信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_material_manufacturer", pkFieldNames = "id", content = "' 生产商名称：'+#entity.name")
    public AjaxResult nccMaterialManufacturerUpdate(@RequestBody NccMaterialManufacturer entity)
    {
        return materialManufacturerService.nccMaterialManufacturerUpdate(entity);
    }

    /**
     * 新增生产商信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 10:45:22
     * @Param entity
     */
    @ApiOperation("新增接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:add')")
    @PostMapping("nccMaterialManufacturerSave")
    @LogC(title = "ncc生产商信息", businessType = BusinessType.INSERT,
            tableNames = "ncc_material_manufacturer", pkFieldNames = "id", content = "' 生产商名称：'+#entity.name")
    public AjaxResult nccMaterialManufacturerSave(@RequestBody NccMaterialManufacturer entity)
    {
        return materialManufacturerService.nccMaterialManufacturerSave(entity);
    }

    /**
     * 定时同步生产厂商信息
     * @return
     */
    @GetMapping("jobMethod")
    public R jobMethod()
    {
        return materialManufacturerService.jobMethodExecute(false);
    }

}
